package com.seamtop.cuber.web.controller;

import com.seamtop.cuber.common.base.DataObject;
import com.seamtop.cuber.common.entriy.CuberMenu;
import com.seamtop.cuber.common.entriy.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

/**
 * Created by feng on 2015/10/22.
 */
@Controller("BaseController")
public class BaseController {

    public void init(HttpServletRequest request,ModelMap model) {
        User user = (User)request.getSession().getAttribute("loginedUser");
        model.addAttribute("user",user);

        HashMap<String,List<String>> menuRelationMap = DataObject.getMenuRelationMap();
        model.addAttribute("menuRelationMap",menuRelationMap);

        HashMap<String,CuberMenu> cuberMenuMap = DataObject.getCuberMenuMap();
        model.addAttribute("cuberMenuMap",cuberMenuMap);
        System.out.println("sys init");
    }


    public void init(ModelMap model) {
        HashMap<String,List<String>> menuRelationMap = DataObject.getMenuRelationMap();
        model.addAttribute("menuRelationMap",menuRelationMap);

        HashMap<String,CuberMenu> cuberMenuMap = DataObject.getCuberMenuMap();
        model.addAttribute("cuberMenuMap",cuberMenuMap);
        System.out.println("sys init");
    }
}
